package helper.request.usermgmt;

import java.sql.SQLException;

import server.dbconnector.DatabaseConnector;
import base.User;

public class ApproveOrRejectRequestCommand implements helper.request.RequestAfterLogin{
	private static final long serialVersionUID = -2459454761589139808L;
	private User targetuser;
	private boolean agree;
	public ApproveOrRejectRequestCommand(boolean agree,User targetuser){
		this.setTargetuser(targetuser);
		this.agree=agree;
	}
	public void setAgree(boolean agree){
		this.agree=agree;
	}
	@Override
	public User getcurrentuser() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int getcurrentuserid() {
		// TODO Auto-generated method stub
		return 0;
	}
	public void setTargetuser(User targetuser) {
		this.targetuser = targetuser;
	}
	public User getTargetuser() {
		return targetuser;
	}
	@Override
	public boolean execute() {
		// TODO Auto-generated method stub
		return false;
	}
	@Override
	public void process(DatabaseConnector dc) throws SQLException{
		if(this.agree)
		dc.commit("update user set Approved=1 where ID="+this.getTargetuser().getid());
		else
		dc.commit("delete from user where ID="+this.getTargetuser().getid());
	}

}
